package com.dou.sample.baserecycleradapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Dou on 2018/1/10.
 */

public abstract class CommenAdapter<T> extends RecyclerView.Adapter<ViewHolder>{

    Context mContext;
    List<T> mData;

    int layoutID;

    public CommenAdapter(Context context, int layoutID, List<T> data){
        this.mContext = context;
        this.mData = data;
        this.layoutID = layoutID;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return ViewHolder.get(mContext, layoutID, parent);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        convert(holder, mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    public abstract void convert(ViewHolder holder, T t);
}
